<template>
  <div class="app-container flex-col minH">
    <div class="topline w100p bgwhite ptb20 radius10 pl10 pr20 justify-between">
      <div>
        <el-input v-model="uid" style="width: 280px" placeholder="搜尋陪玩ID..." :prefix-icon="Search" class="search" />


      </div>
      <div class="noshrink">
        <el-button class="btn2" @click="search()">查詢</el-button>
        <el-button class="btn1" @click="reset()">重置</el-button>
      </div>
    </div>
    <div class="mt15 radius10 hidden pb15 flex1 bgwhite  flex-col w100p">
      <div class="flex1 w100p ">
        <el-table :data="tableData" style="width: 100%" cell-class-name="tbcell" header-cell-class-name="hdcell">
          <el-table-column prop="uid" label="陪玩訊息">
            <template #default="scope">
              <span @click="showUser(scope.row.uid)">ID:{{ scope.row.uid }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="classifyid" label="陪玩分類id" />
          <el-table-column prop="classifyname" label="陪玩分類名稱" />
          <el-table-column prop="price" label="價格" />

          <el-table-column prop="created_at" label="創建時間" sortable />
        </el-table>
      </div>

      <div class="  plr20 mlauto mt15">
        <el-pagination v-model:current-page="currentPage" prev-text="上一頁" next-text="下一頁" :default-page-size="15" :small="small" :disabled="disabled" :background="true" layout="prev, pager, next, jumper" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </div>
    </div>

  </div>
</template>

<script setup>
import { Search } from '@element-plus/icons-vue'
import { ref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router';
import { priceList } from '@/api/player.js'
const route = useRoute()
import { inject } from 'vue';
const showUser = inject('showUser');
onMounted(() => {
  if (route.query.uid) {
    uid.value = route.query.uid
    getPriceList()
  } else {
    getPriceList()

  }
})
// 服务价格
const getPriceList = () => {
  priceList(
    {
      uid: uid.value,
      page: currentPage.value
    }
  ).then((res) => {
    console.log('服务价格', res)
    tableData.value = res.data.data
    total.value = res.data.total
  })
}
const search = () => {
  getPriceList()
}
const reset = () => {
  uid.value = ''
  getPriceList()

}
const uid = ref('')
const dialogTableVisible = ref(false)
const dialogType = ref(1)
const dialogShow = (type) => {
  console.log('dialog----show----')
  dialogType.value = type
  dialogTableVisible.value = true
}
const tableData = ref([])
const currentPage = ref(1)
const total = ref(0)
const handleSizeChange = (val) => {
  console.log(`${val} items per page`)
}
const handleCurrentChange = (val) => {
  console.log(`current page: ${val}`)
  getPriceList()
}
const router = useRouter()
const toAdd = () => {
  console.log(router)
  router.push({ path: 'addNotice' })
}
const edit = (type) => {
  router.push({ path: 'signEdit' })
}
</script>

<style lang="scss" scoped>
.search {
  overflow: hidden;
  border-radius: 10px !important;
  // padding: 5px 0px;
}

:deep(.el-input__wrapper) {
  box-shadow: none;
}
</style>
<style></style>
 